package com.itheima.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


@Component
public class GlobalFilterTest implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        //全局过滤器，无需配置即可启动
        System.out.println("全局过滤器--启动 GlobalFilterTest执行");
        return chain.filter(exchange);//放行 exchange中包含请求响应的各种参数
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
